<template>
	<view>
		<navbar :isback="true" title="分成比例"></navbar>
		<u-loading-page icon-size="100rpx" :loading="loading" loading-text="驼乡生活信息超市"></u-loading-page>
		<view class="" v-if='!loading'>
			<image src="/static/msg/blbg.png" class="blbg" mode=""></image>
			<view class="fcbl">
				您的分成比例设定为<text style="color: #0384FC;">{{info.rate}}%</text>
			</view>
			<view class="footer" v-if="info.status==1">
				<u-button text="取消" @click="back" shape='circle' color="#9FA0A1" size="large"
					:customStyle="{height:'103rpx',width:'257rpx'}"></u-button>
				<u-button text="确认" @click="submit" :loading="btnloading" shape='circle' color="linear-gradient(90deg, #0384FC 0%, #5E77FD 100%)" size="large"
					:customStyle="{height:'103rpx',width:'257rpx'}"></u-button>
			</view>
		</view>
	</view>
</template>

<script>
	import user from '@/api/_user.js'
	export default {
		data() {
			return {
				btnloading: false,
				info:{},
				loading:true
			};
		},
		methods:{
			back(){
				
				uni.navigateBack()
			},
			getfc(){
				user.myRate().then(res=>{
					this.loading=false
					if(res.data.code==1){
						this.info=res.data.data
					}else{
						uni.$u.toast('暂无分成')
						uni.navigateBack()
					}
				})
			},
			submit(){
				let _this=this
				this.btnloading=true
				user.updateRate({status:2}).then(res=>{
					
					if(res.data.code==1){
						uni.$u.toast('设置成功')
						setTimeout(()=>{
							_this.btnloading=false
							uni.navigateBack()
						},1000)
					}else{
						uni.$u.toast('设置失败')
					}
				})
			}
		},
		onLoad() {
			this.getfc()
		}
	}
</script>

<style lang="scss">
	.blbg {
		width: 485rpx;
		height: 408rpx;
		margin: 200rpx 0 0 165rpx;
	}
	.fcbl{
		font-family: PingFang SC;
		font-weight: 500;
		font-size: 30rpx;
		color: #000000;
		line-height: 30rpx;
		text-align: center;
		margin-top: -70rpx;
	}
	.footer{
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 99rpx 96rpx 0;
	}
</style>